<xs:schema targetNamespace="urn:nhibernate-configuration-2.2-x-factories" xmlns="urn:nhibernate-configuration-2.2-x-factories" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:NS="urn:nhibernate-configuration-2.2-x-factories">
	<xs:annotation>
		<xs:documentation>
			NHibernate-X-Factories v1.0.1, Copyright 2013 roydukkey, 2013-06-20 (Thu, 20 June 2013).
			Dual licensed under the MIT (http://www.roydukkey.com/mit) and GPL Version 2 (http://www.roydukkey.com/gpl) licenses.
			This schema was adapted to allow multiple session-factory sections.
		</xs:documentation>
	</xs:annotation>
	<!-- Type definitions -->
	<xs:element name="hibernate-configuration">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="bytecode-provider" minOccurs="0" maxOccurs="1" >
          <xs:annotation>
            <xs:documentation>
              There are 3 default short-cut values
              - lcg     : default for .NET2.0 and higher.
              - codedom : CodeDOM-based bytecode provider (mostly for .NET1.1).
              - null    : Disable the reflection optimization completely.
              In addition you can specify the AssemblyQualifiedName of your custom bytecode-provider (implementation of IBytecodeProvider).
              Note: the bytecode-provider will be tooks in account only when specified in the app.config or web.config.
            </xs:documentation>
          </xs:annotation>
        </xs:element>
				<xs:element ref="reflection-optimizer" maxOccurs="1" minOccurs="0" />
				<xs:element ref="session-factory" minOccurs="0" maxOccurs="unbounded" />
			</xs:sequence>
		</xs:complexType>
		<xs:unique name="SessionFactoryName">
			<xs:selector xpath="NS:session-factory" />
			<xs:field xpath="@name" />
		</xs:unique>
	</xs:element>
	<xs:element name="class-cache">
		<xs:complexType>
			<xs:sequence>
			</xs:sequence>
			<xs:attribute name="class" type="xs:string" use="required" />
			<xs:attributeGroup ref="cacheSpecification" />
			<xs:attribute name="include">
				<xs:simpleType>
					<xs:restriction base="xs:string">
						<xs:enumeration value="all" />
						<xs:enumeration value="non-lazy" />
					</xs:restriction>
				</xs:simpleType>
			</xs:attribute>
		</xs:complexType>
	</xs:element>
	<xs:element name="collection-cache">
		<xs:complexType>
			<xs:sequence />
			<xs:attribute name="collection" type="xs:string" use="required" />
			<xs:attributeGroup ref="cacheSpecification" />
		</xs:complexType>
	</xs:element>
	<xs:element name="mapping">
		<xs:annotation>
			<xs:documentation>
			There are 3 possible combinations of mapping attributes
			1 - resource &amp; assembly:  NHibernate will read the mapping resource from the specified assembly
			2 - file only: NHibernate will read the mapping from the file.
			3 - assembly only: NHibernate will find all the resources ending in hbm.xml from the assembly.
			</xs:documentation>
		</xs:annotation>
		<xs:complexType>
			<xs:attribute name="resource" />
			<xs:attribute name="file" />
			<xs:attribute name="assembly" />
		</xs:complexType>
	</xs:element>
	<xs:element name="property">
		<xs:complexType>
			<xs:simpleContent>
				<xs:extension base="xs:string">
					<xs:attribute name="name" use="required">
						<xs:simpleType>
							<xs:restriction base="xs:string">
								<xs:enumeration value="connection.provider" />
								<xs:enumeration value="connection.driver_class" />
								<xs:enumeration value="connection.connection_string" />
								<xs:enumeration value="connection.isolation" />
								<xs:enumeration value="connection.release_mode" />
								<xs:enumeration value="connection.connection_string_name" />
								<xs:enumeration value="dialect" />
								<xs:enumeration value="default_schema" />
								<xs:enumeration value="show_sql" />
								<xs:enumeration value="max_fetch_depth" />
								<xs:enumeration value="current_session_context_class" />
								<xs:enumeration value="transaction.factory_class" />
								<xs:enumeration value="cache.provider_class" />
								<xs:enumeration value="cache.use_query_cache" />
								<xs:enumeration value="cache.query_cache_factory" />
								<xs:enumeration value="cache.use_second_level_cache" />
								<xs:enumeration value="cache.region_prefix" />
								<xs:enumeration value="cache.use_minimal_puts" />
								<xs:enumeration value="cache.default_expiration" />
								<xs:enumeration value="query.substitutions" />
								<xs:enumeration value="query.factory_class" />
								<xs:enumeration value="query.imports" />
								<xs:enumeration value="hbm2ddl.auto" />
								<xs:enumeration value="hbm2ddl.keywords" />
								<xs:enumeration value="sql_exception_converter" />
								<xs:enumeration value="adonet.wrap_result_sets" />
								<xs:enumeration value="prepare_sql" />
								<xs:enumeration value="command_timeout" />
								<xs:enumeration value="adonet.batch_size" />
								<xs:enumeration value="use_proxy_validator" />
								<xs:enumeration value="xml.output_stylesheet" />
								<xs:enumeration value="generate_statistics" />
								<xs:enumeration value="query.startup_check" />
								<xs:enumeration value="default_catalog" />
								<xs:enumeration value="proxyfactory.factory_class" />
								<xs:enumeration value="adonet.factory_class" />
								<xs:enumeration value="default_batch_fetch_size" />
								<xs:enumeration value="default_entity_mode" />
								<xs:enumeration value="use_sql_comments" />
								<xs:enumeration value="format_sql" />
								<xs:enumeration value="collectiontype.factory_class" />
                <xs:enumeration value="order_inserts" />
              </xs:restriction>
						</xs:simpleType>
					</xs:attribute>
				</xs:extension>
			</xs:simpleContent>
		</xs:complexType>
	</xs:element>
	<xs:element name="session-factory">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="property" minOccurs="0" maxOccurs="unbounded" />
				<xs:element ref="mapping" minOccurs="0" maxOccurs="unbounded" />
				<xs:choice minOccurs="0" maxOccurs="unbounded">
					<xs:element ref="class-cache" />
					<xs:element ref="collection-cache" />
				</xs:choice>
				<xs:element ref="event" minOccurs="0" maxOccurs="unbounded" />
				<xs:element ref="listener" minOccurs="0" maxOccurs="unbounded" />
			</xs:sequence>
			<xs:attribute name="name" use="required" />
		</xs:complexType>
	</xs:element>
	<xs:attributeGroup name="cacheSpecification">
		<xs:attribute name="region" type="xs:string" use="optional" />
		<xs:attribute name="usage" use="required">
			<xs:simpleType>
				<xs:restriction base="xs:string">
					<xs:enumeration value="read-only" />
					<xs:enumeration value="read-write" />
					<xs:enumeration value="nonstrict-read-write" />
					<xs:enumeration value="transactional" />
				</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
	</xs:attributeGroup>
	<xs:element name="event">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="listener" minOccurs="1" maxOccurs="unbounded" />
			</xs:sequence>
			<xs:attribute name="type" type="listenerType" use="required" />
		</xs:complexType>
	</xs:element>
	<xs:element name="listener">
		<xs:complexType>
			<xs:sequence />
			<xs:attribute name="class" type="xs:string" use="required" />
			<xs:attribute name="type" type="listenerType" use="optional" />
		</xs:complexType>
	</xs:element>
	<xs:simpleType name="listenerType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="auto-flush" />
			<xs:enumeration value="merge" />
			<xs:enumeration value="create" />
			<xs:enumeration value="create-onflush" />
			<xs:enumeration value="delete" />
			<xs:enumeration value="dirty-check" />
			<xs:enumeration value="evict" />
			<xs:enumeration value="flush" />
			<xs:enumeration value="flush-entity" />
			<xs:enumeration value="load" />
			<xs:enumeration value="load-collection" />
			<xs:enumeration value="lock" />
			<xs:enumeration value="refresh" />
			<xs:enumeration value="replicate" />
			<xs:enumeration value="save-update" />
			<xs:enumeration value="save" />
			<xs:enumeration value="pre-update" />
			<xs:enumeration value="update" />
			<xs:enumeration value="pre-load" />
			<xs:enumeration value="pre-delete" />
			<xs:enumeration value="pre-insert" />
			<xs:enumeration value="post-load" />
			<xs:enumeration value="post-insert" />
			<xs:enumeration value="post-update" />
			<xs:enumeration value="post-delete" />
			<xs:enumeration value="post-commit-update" />
			<xs:enumeration value="post-commit-insert" />
			<xs:enumeration value="post-commit-delete" />
			<xs:enumeration value="pre-collection-recreate" />
			<xs:enumeration value="pre-collection-remove" />
			<xs:enumeration value="pre-collection-update" />
			<xs:enumeration value="post-collection-recreate" />
			<xs:enumeration value="post-collection-remove" />
			<xs:enumeration value="post-collection-update" />
		</xs:restriction>
	</xs:simpleType>
	<xs:element name="bytecode-provider">
		<xs:complexType>
			<xs:sequence>
			</xs:sequence>
			<xs:attribute name="type" default="lcg">
				<xs:simpleType>
					<xs:restriction base="xs:string">
						<xs:enumeration value="codedom" />
						<xs:enumeration value="lcg" />
						<xs:enumeration value="null" />
					</xs:restriction>
				</xs:simpleType>
			</xs:attribute>
		</xs:complexType>
	</xs:element>
	<xs:element name="reflection-optimizer">
		<xs:complexType>
			<xs:sequence />
			<xs:attribute name="use" type="xs:boolean" />
		</xs:complexType>
	</xs:element>
</xs:schema>